<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
		</style>
	</head>
	<body>
		<div id="divselect">
			<select id="select" name="select">
				<option value ="">选择大小</option>
				<option value ="big">大</option>
				<option value ="small">小</option>
			</select>
		</div>
		<div id="div1">
			<img src='../img/摇色子/1.jpg' id="picture" height="200px" ; width="200px";>
		</div>
		<div id="div2">
			<button type="button" onclick="Rock();">开始</button>
		</div>
	</body>
	<script type="text/javascript">
		function Rock(){
			var picture = document.getElementById('picture');
			var select = document.getElementById('select');
			if(select.value == ''){
				alert('请选择大小');
				location.reload();
			}
			var Num = 0 ;
			var Sum = 0;
			var Interval = setInterval(function(){
				Num = GetNum();
				picture.src = '../img/摇色子/'+Num+'.jpg';
				Sum++;
				if(Sum == 10){
					clearInterval(Interval);
					setTimeout(function(){
						if(select.value == 'big'){
							if(Num > 3){
								alert('恭喜你猜对了！');
							}else{
								alert('猜错了！');
							}
						}
						if(select.value == 'small'){
							if(Num < 3){
								alert('恭喜猜对了!');
							}else{
								alert('猜错了!');
							}
						}
					})
				}
			},1000);
		}
		function GetNum(){
			var MathNum = 0;
			while(true){
				MathNum = Math.floor(Math.random()*10);
				if(MathNum > 0 && MathNum < 7){
					break;
				}
			}
			return MathNum;
		}
	</script>
</html>
